# Maintainer: David Runge <dvzrv@archlinux.org>

_name=importlib_resources
pkgname=python-importlib_resources
pkgver=5.12.0
pkgrel=2
pkgdesc="Design and implementation for a planned importlib.resources"
arch=(any)
url="https://github.com/python/importlib_resources"
license=(Apache)
depends=(python-zipp)
makedepends=(python-build python-installer python-setuptools-scm python-toml python-wheel)
checkdepends=(python-pytest python-tests)
provides=(python-importlib-resources)
source=(https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz)
sha512sums=('00875d82cf3d2103872079ee2882c4000cc65141d97988265721cc6861a64dfe480e5c2191a2b22d0b9b9e42de1fc06d54f6d8eb4f37aaf91a819ee9306dc06f')
b2sums=('bbae92bd62b54afc0093f8daa8f0fabaf18da7b2c9c578a2e6b6b7cc3207384e4fd037762c4ac8bc862900ac2da112a3b8ae236b1d3ca072c739f2d1ad3edd36')

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  cd $_name-$pkgver
  pytest -vv
}

package() {
  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 README.rst -t "$pkgdir/usr/share/doc/$pkgname/"
  # remove tests
  rm -frv "$pkgdir/$_site_packages/$_name/tests/"
}
